package recycle.service;

import io.vertx.core.Future;
import io.vertx.core.json.JsonObject;
import recycle.pojo.Category;
import recycle.repository.CategoryRepository;

import java.util.List;

public class CategoryService {
    private final CategoryRepository categoryRepository;

    public CategoryService(CategoryRepository categoryRepository) {
        this.categoryRepository = categoryRepository;
    }

    public Future<Long> create(Category category) {
        return categoryRepository.insert(category);
    }

    public Future<JsonObject> list(Category category , Integer pageNum, Integer pageSize) {
        return categoryRepository.selectList( category , pageNum, pageSize);
    }

    public Future<List<Category>> list() {
        return categoryRepository.selectList( );
    }

    public Future<Category> details(Long id) {
        return categoryRepository.selectById(id);
    }

    public Future<Void> update(Category category) {
        return categoryRepository.updateById(category);
    }

    public Future<Void> delete(Long id) {
        return categoryRepository.deleteById(id);
    }

}